/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ongmanager.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author wbettencourt
 */
@Entity
@Table(name = "beneficiario")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Beneficiario.findAll", query = "SELECT b FROM Beneficiario b"),
    @NamedQuery(name = "Beneficiario.findByIdBeneficiario", query = "SELECT b FROM Beneficiario b WHERE b.idBeneficiario = :idBeneficiario"),
    @NamedQuery(name = "Beneficiario.findByTipo", query = "SELECT b FROM Beneficiario b WHERE b.tipo = :tipo"),
    @NamedQuery(name = "Beneficiario.findByDescripcion", query = "SELECT b FROM Beneficiario b WHERE b.descripcion = :descripcion"),
    @NamedQuery(name = "Beneficiario.findByCreatedAt", query = "SELECT b FROM Beneficiario b WHERE b.createdAt = :createdAt")})
public class Beneficiario implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "IdBeneficiario")
    private Integer idBeneficiario;
    @Basic(optional = false)
    @Column(name = "Tipo")
    private String tipo;
    @Column(name = "Descripcion")
    private String descripcion;
    @Basic(optional = false)
    @Column(name = "created_at")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdAt;
    @JoinTable(name = "ong_beneficiario", joinColumns = {
        @JoinColumn(name = "IdBeneficiario", referencedColumnName = "IdBeneficiario")}, inverseJoinColumns = {
        @JoinColumn(name = "IdOng", referencedColumnName = "IdONG")})
    @ManyToMany
    private List<Ong> ongList;

    public Beneficiario() {
    }

    public Beneficiario(Integer idBeneficiario) {
        this.idBeneficiario = idBeneficiario;
    }

    public Beneficiario(Integer idBeneficiario, String tipo, Date createdAt) {
        this.idBeneficiario = idBeneficiario;
        this.tipo = tipo;
        this.createdAt = createdAt;
    }

    public Integer getIdBeneficiario() {
        return idBeneficiario;
    }

    public void setIdBeneficiario(Integer idBeneficiario) {
        this.idBeneficiario = idBeneficiario;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    @XmlTransient
    public List<Ong> getOngList() {
        return ongList;
    }

    public void setOngList(List<Ong> ongList) {
        this.ongList = ongList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idBeneficiario != null ? idBeneficiario.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Beneficiario)) {
            return false;
        }
        Beneficiario other = (Beneficiario) object;
        if ((this.idBeneficiario == null && other.idBeneficiario != null) || (this.idBeneficiario != null && !this.idBeneficiario.equals(other.idBeneficiario))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ongmanager.model.Beneficiario[ idBeneficiario=" + idBeneficiario + " ]";
    }
    
}
